﻿using System;
using System.Configuration;

namespace OOT.Frontend.Controls
{
	public partial class Login : System.Web.UI.UserControl
	{
		protected void Page_Load(object sender, EventArgs e)
		{

		}

		protected void btnLogin_Click(object sender, EventArgs e)
		{
			if (Authenticate(txtName.Text, txtPassw.Text))
			{
				Session.Add("User", txtName.Text);
				Response.Redirect("default.aspx");
			}
			else
			{
				Response.Redirect("login.aspx");
			}
		}

		private bool Authenticate(string login, string password)
		{
			return (ConfigurationManager.AppSettings.HasKeys() && ConfigurationManager.AppSettings[login].ToString() == password);
		}
	}
}